package com.wangyonghui.attendanceserver.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wangyonghui.attendanceserver.entity.Emp;
import com.wangyonghui.attendanceserver.entity.vo.EmpVO;
import com.wangyonghui.attendanceserver.service.IEmpService;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Arrays;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author wangyonghui
 * @since 2020-03-29
 */
@RestController
@RequestMapping("/emp")
public class EmpController {

    @Resource
    private IEmpService empService;

    /**
     *  根据条件查询 列表展示 分页功能
     * @param empVO
     * @param current
     * @param size
     * @return
     */
    @RequestMapping("list")
    public IPage<Emp> list(EmpVO empVO, @RequestParam(defaultValue = "1") Integer current, @RequestParam(defaultValue = "3") Integer size){
        Page<Emp> page=new Page<>(current, size);
        return empService.selectPageVo(page,empVO);
    }

    /**
     *  考勤记录 批删/单删
     * @param ids
     * @return
     */
    @RequestMapping("deleteByIds")
    public boolean deleteByIds(Integer []ids){
        return empService.removeByIds(Arrays.asList(ids));
    }

    /**
     *  考勤记录添加或修改
     * @param emp
     * @return
     */
    @RequestMapping("saveOrUpdate")
    public boolean saveOrUpdate(@RequestBody Emp emp){
        return empService.saveOrUpdate(emp);
    }
}
